package com.beiing.tianshuai.tianshuai.mine.ui;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;

import com.beiing.tianshuai.tianshuai.R;
import com.beiing.tianshuai.tianshuai.activity.RequestAddFriendActivity;
import com.beiing.tianshuai.tianshuai.activity.SinglePicPreviewActivity;
import com.beiing.tianshuai.tianshuai.adapter.PersonalDynamicAdapter;
import com.beiing.tianshuai.tianshuai.anim.LikeAnimator;
import com.beiing.tianshuai.tianshuai.base.BaseActivity;
import com.beiing.tianshuai.tianshuai.dongtai.DynamicForwardActivity;
import com.beiing.tianshuai.tianshuai.dongtai.DynamicRelayDetailActivity;
import com.beiing.tianshuai.tianshuai.dongtai.view.DynamicDetailActivity;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.entity.DynamicBean;
import com.beiing.tianshuai.tianshuai.entity.FollowResultBean;
import com.beiing.tianshuai.tianshuai.entity.PersonalDynamicBean;
import com.beiing.tianshuai.tianshuai.entity.PersonalInfoBean;
import com.beiing.tianshuai.tianshuai.mine.presenter.NewPersonalIndexPresenter;
import com.beiing.tianshuai.tianshuai.mine.view.NewPersonalIndexViewImpl;
import com.beiing.tianshuai.tianshuai.nim.session.SessionHelper;
import com.beiing.tianshuai.tianshuai.util.DensityUtils;
import com.beiing.tianshuai.tianshuai.util.DisplayUtil;
import com.beiing.tianshuai.tianshuai.util.LogUtils;
import com.beiing.tianshuai.tianshuai.widget.ActionSheet;
import com.beiing.tianshuai.tianshuai.widget.FooterView;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.tianshuai.easypopup.EasyPopup;
import com.tianshuai.easypopup.HorizontalGravity;
import com.tianshuai.easypopup.VerticalGravity;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import me.shihao.library.XStatusBarHelper;

public class NewPersonalIndexActivity extends BaseActivity implements NewPersonalIndexViewImpl {

    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.srl_my_refresh_layout)
    SwipeRefreshLayout mRefreshLayout;
    @BindView(R.id.rv_dynamics)
    RecyclerView mRvDynamics;
    @BindView(R.id.toolbar_btn_back)
    ImageButton mToolbarBack;
    @BindView(R.id.toolbar_btn_information)
    ImageButton mBtnPersonalInfo;
    @BindView(R.id.toolbar_title)
    TextView mToolbarTitle;

    /**
     * TAG 打印log日志的时候作为标识
     */
    private static final String TAG = "NewPersonalIndex";

    /**
     * 更多菜单
     */
    private EasyPopup mPopup;

    /**
     * 动态列表适配器
     */
    private PersonalDynamicAdapter mAdapter;

    /**
     * 页容量
     */
    private final int PAGE_SIZE = 15;

    /**
     * 判断是否加载完成
     */
    private boolean isLoadFinished = true;

    /**
     * 当前总条目数量
     */
    private int mLastItemNum = 0;

    /**
     * presenter
     */
    private NewPersonalIndexPresenter mPresenter;

    /**
     * 当前登录用户的id
     */
    private String mUid;

    /**
     * 当前空间主人的id
     */
    private String mToId;

    /**
     * 获取动态时进行网络重连的次数统计
     */
    private int retryCount = 0;

    /**
     * 是否处于刷新状态
     */
    private boolean isRefresh;

    /**
     * 用户个人资料
     */
    private PersonalInfoBean mPersonalInfoBean = new PersonalInfoBean();

    public static void start(Context context, String uid){
        Intent intent = new Intent(context, NewPersonalIndexActivity.class);
        intent.putExtra("uid", uid);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_new_personal_index;
    }

    @Override
    protected void init() {

        mUid = com.beiing.tianshuai.tianshuai.entity.UserInfoBean.getUid(mContext);
        Intent intent = getIntent();
        mToId = intent.getStringExtra("uid");

        mRefreshLayout.setProgressViewOffset(true, 60, 260);

        initStatusBar();
        initRecyclerView();
        initPopupWindow();
        initPresenter();
        initListener();
    }

    /**
     * 初始化沉浸式状态栏
     */
    private void initStatusBar() {
        QMUIStatusBarHelper.setStatusBarDarkMode(this);
        XStatusBarHelper.immersiveStatusBar(this, 0);
        int statusBarHeight = XStatusBarHelper.getStatusBarHeight(this);
        mToolbar.setPadding(0, statusBarHeight, 0, 0);
    }

    /**
     * 初始化RecyclerView
     */
    private void initRecyclerView() {
        // 添加布局管理器
        LinearLayoutManager layoutManager = new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
        mRvDynamics.setLayoutManager(layoutManager);
        mRvDynamics.setNestedScrollingEnabled(false);
//        mRvDynamics.addItemDecoration(
//                new RecycleViewDivider(
//                        mContext, LinearLayoutManager.HORIZONTAL, DensityUtils.dp2px(mContext, 10),
//                        ContextCompat.getColor(mContext, R.color.common_gray_background))
//        );

        // 添加适配器
        mAdapter = new PersonalDynamicAdapter(mContext, mPersonalInfoBean);
        mRvDynamics.setAdapter(mAdapter);
    }

    /**
     * 初始化更多菜单
     */
    private void initPopupWindow() {
        mPopup = new EasyPopup(mContext)
                .setContentView(R.layout.menu_personal_index_more)
                .setAnimationStyle(R.style.QQPopAnim)
                .setFocusAndOutsideEnable(true)
                .createPopup();

        // 更多菜单投稿按钮
        TextView publish = mPopup.getView(R.id.btn_publish);
        publish.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPopup.dismiss();
                Intent intent = new Intent(mContext, PersonalPublishActivity.class);
                intent.putExtra("uid", mToId);
                startActivity(intent);
            }
        });

        // 更多菜单收藏按钮
        TextView collection = mPopup.getView(R.id.btn_collection);
        collection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPopup.dismiss();
                Intent intent = new Intent(mContext, MyCollectionActivity.class);
                intent.putExtra("uid", mToId);
                startActivity(intent);
            }
        });

        // 更多菜单关注/粉丝按钮
        TextView followedAndFans = mPopup.getView(R.id.btn_followed_fans);
        followedAndFans.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPopup.dismiss();
                Intent intent = new Intent(mContext, FansAndIdolActivity.class);
                intent.putExtra("toUid", mToId);
                startActivity(intent);
            }
        });
    }

    /**
     * 初始化presenter
     * 请求用户个人资料
     * 请求动态列表第一页的内容
     */
    private void initPresenter() {
        mPresenter = new NewPersonalIndexPresenter(this);
        mPresenter.getUserInfo(mToId, mUid);
        mPresenter.getPersonalDynamicResult(mUid, mToId, mLastItemNum, PAGE_SIZE);
    }

    /**
     * 初始化监听事件
     */
    private void initListener() {
        // 刷新
        mRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                mLastItemNum = 0;
                isRefresh = true;
                mPresenter.getUserInfo(mToId, mUid);
                mPresenter.getPersonalDynamicResult(mUid, mToId, mLastItemNum, PAGE_SIZE);
            }
        });

        // 个人资料
        mBtnPersonalInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!TextUtils.equals(com.beiing.tianshuai.tianshuai.entity.UserInfoBean.getUid(mContext), mToId)) {
                    Intent intent = new Intent(mContext, PersonalDataCardActivity.class);
                    intent.putExtra("uid", mToId);
                    startActivity(intent);
                } else {
                    Intent intent = new Intent(mContext, PersonalInformationActivity.class);
                    startActivity(intent);
                }
            }
        });

        mAdapter.setOnAvatarClickListener(new PersonalDynamicAdapter.OnAvatarClickListener() {
            @Override
            public void onAvatarClick(String avatarPath) {
                if (!TextUtils.isEmpty(avatarPath)) {
                    Intent intent = new Intent(mContext, SinglePicPreviewActivity.class);
                    intent.putExtra("avatarUrl", avatarPath);
                    startActivity(intent);
                }
            }
        });

        // 点击查看关注与粉丝
        mAdapter.setOnFansClickListener(new PersonalDynamicAdapter.OnFansClickListener() {
            @Override
            public void onFansClick(String uid, int currentTab) {
                Intent intent = new Intent(mContext, FansAndIdolActivity.class);
                intent.putExtra("toUid", uid);
                intent.putExtra("currentTab", currentTab);
                startActivity(intent);
            }
        });

        mAdapter.setOnCenterMenuClickListener(new PersonalDynamicAdapter.OnCenterMenuClickListener() {
            @Override
            public void onFollowClick() {
                if (TextUtils.isEmpty(mUid)) {
                    toLogin();
                } else if (TextUtils.equals(mUid, mToId)) {
                    showShortText("不可以关注自己哟~");
                } else {
                    mPresenter.setFollowed(mUid, mToId);
                }
            }

            @Override
            public void onAddFriendClick(boolean isFriend) {
                if (TextUtils.isEmpty(mUid)) {
                    toLogin();
                } else if (TextUtils.equals(mUid, mToId)) {
                    showShortText("不能添加自己为好友噢~");
                } else {
                    if (!isFriend) {
                        Intent intent = new Intent(mContext, RequestAddFriendActivity.class);
                        intent.putExtra("uid", mToId);
                        startActivity(intent);
                    }
                }
            }

            @Override
            public void onChatClick(boolean isFriend, String photo) {
                if (TextUtils.isEmpty(mUid)) {
                    toLogin();
                } else if (TextUtils.equals(mUid, mToId)) {
                    showShortText("不能和自己聊天呃~");
                } else {
                    if (isFriend) {
                        SessionHelper.startP2PSession(mContext, mToId);
                    } else {
                        showShortText("请先添加对方为好友");
                    }
                }
            }

            @Override
            public void onMoreClick(View view) {
                int i = view.getLayoutParams().width / 2 - DensityUtils.dp2px(mContext, 17);
                mPopup.showAtAnchorView(view, VerticalGravity.BELOW, HorizontalGravity.ALIGN_RIGHT, i, -DensityUtils.dp2px(mContext, 10));
            }
        });

        // 返回
        mToolbarBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });

        // 动态item的点击事件 点赞 转发 评论
        mAdapter.setListener(new PersonalDynamicAdapter.OnItemClickListener() {
            @Override
            public void OnCommentClickListener(int position, PersonalDynamicBean.DataBean.NumberBean bean) {
                if (TextUtils.isEmpty(mUid)) {
                    toLogin();
                    return;
                }
                DynamicBean.DataBean.DynamicsBean dynamicsBean = new DynamicBean.DataBean.DynamicsBean();
                dynamicsBean.setContent(bean.getContent());
                dynamicsBean.setName(bean.getName());
                List<PersonalDynamicBean.DataBean.NumberBean.PicBean> pic = bean.getPic();
                List<DynamicBean.DataBean.DynamicsBean.PicBean> pics = new ArrayList<>();
                for (PersonalDynamicBean.DataBean.NumberBean.PicBean picBean : pic) {
                    DynamicBean.DataBean.DynamicsBean.PicBean rBean = new DynamicBean.DataBean.DynamicsBean.PicBean();
                    rBean.setDid(picBean.getDid());
                    rBean.setId(picBean.getId());
                    rBean.setPicname(picBean.getPicname());
                    pics.add(rBean);
                }
                dynamicsBean.setPhoto(bean.getPhoto());
                dynamicsBean.setUnit(bean.getUnit());
                dynamicsBean.setIsThing(bean.getIsThing());
                dynamicsBean.setThing(bean.getThing());
                dynamicsBean.setRelay(bean.getRelay());
                dynamicsBean.setPic(pics);
                dynamicsBean.setUid(bean.getUid());
                dynamicsBean.setId(bean.getId());
                Intent intent = new Intent();
                if ("1".equals(bean.getTableType())) {
                    intent.setClass(mContext, DynamicDetailActivity.class);
                } else {
                    intent.setClass(mContext, DynamicRelayDetailActivity.class);
                }
                intent.putExtra("dynamic_id", bean.getIdOne());
                Bundle bundle = new Bundle();
                bundle.putSerializable("dynamic", dynamicsBean);
                intent.putExtras(bundle);
                startActivity(intent);
            }

            @Override
            public void OnLikeClickListener(int position, boolean isLiked, View view, String aid,
                                            TextView tvAddOne) {
                if (TextUtils.isEmpty(mUid)) {
                    toLogin();
                    return;
                }
                TextView likeView = (TextView) view;
                int likeNum = Integer.parseInt(likeView.getText().toString());
                if (isLiked) {
                    likeNum--;
                    LikeAnimator.disLikeAnimator(mContext, likeView);
                } else {
                    likeNum++;
                    LikeAnimator.thumbAnimator(mContext, likeView);
                    LikeAnimator.addOneTextAnimator(mContext, tvAddOne);
                }
                likeView.setText(String.valueOf(likeNum));
                mPresenter.setLikeState(com.beiing.tianshuai.tianshuai.entity.UserInfoBean.getUid(mContext), aid, mToId);
            }

            @Override
            public void OnReprintClickListener(int position, PersonalDynamicBean.DataBean.NumberBean bean) {
                if (TextUtils.isEmpty(mUid)) {
                    toLogin();
                    return;
                }
                DynamicBean.DataBean.DynamicsBean dynamicsBean = new DynamicBean.DataBean.DynamicsBean();
                dynamicsBean.setContent(bean.getContent());
                dynamicsBean.setName(bean.getName());
                List<PersonalDynamicBean.DataBean.NumberBean.PicBean> pic = bean.getPic();
                List<DynamicBean.DataBean.DynamicsBean.PicBean> pics = new ArrayList<>();
                for (PersonalDynamicBean.DataBean.NumberBean.PicBean picBean : pic) {
                    DynamicBean.DataBean.DynamicsBean.PicBean rBean = new DynamicBean.DataBean.DynamicsBean.PicBean();
                    rBean.setDid(picBean.getDid());
                    rBean.setId(picBean.getId());
                    rBean.setPicname(picBean.getPicname());
                    pics.add(rBean);
                }
                dynamicsBean.setPic(pics);
                dynamicsBean.setUid(bean.getUid());
                dynamicsBean.setId(bean.getId());
                Intent intent = new Intent();
                intent.setClass(mContext, DynamicForwardActivity.class);
                Bundle bundle = new Bundle();
                bundle.putSerializable("dynamic", dynamicsBean);
                intent.putExtras(bundle);
                startActivity(intent);
            }

            @Override
            public void OnMenuClickListener(int position, PersonalDynamicBean.DataBean.NumberBean bean) {
                showDynamicMenu(NewPersonalIndexActivity.this, position, bean);
            }

            @Override
            public void OnRNameClickListener(int position, PersonalDynamicBean.DataBean.NumberBean bean) {
                String fromUid = bean.getUid();
                Intent intent = new Intent(mContext, NewPersonalIndexActivity.class);
                intent.putExtra("uid", fromUid);
                startActivity(intent);
            }
        });

        mRvDynamics.addOnScrollListener(new RecyclerView.OnScrollListener() {

            private boolean mIsDarkMode = true;
            private boolean mIsLightMode = false;
            int headerHeight = (int) (DisplayUtil.getMobileHeight(mContext) * 0.4);
            float minHeaderHeight = getResources().getDimension(R.dimen.custom_action_bar_default_height_material);
            float headerBarOffsetY = headerHeight - minHeaderHeight;//Toolbar与header高度的差值
            int scrollY = 0;

            @Override
            public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                super.onScrollStateChanged(recyclerView, newState);
                int topRowVerticalPosition =
                        (recyclerView == null || recyclerView.getChildCount() == 0) ? 0 : recyclerView.getChildAt(0).getTop();
                mRefreshLayout.setEnabled(topRowVerticalPosition >= 0);
            }

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                scrollY += dy;
                LogUtils.i(String.valueOf(scrollY), TAG);
                //变化率
                float offset = 1 - Math.max((headerBarOffsetY - scrollY) / headerBarOffsetY, 0.00f);
                //Toolbar背景色透明度
                if (scrollY >= 0) {
                    mToolbar.setBackgroundColor(Color.argb((int) (offset * 255), 255, 255, 255));
                }
                if (offset >= 0.80 && mIsDarkMode) {
                    if (!mIsLightMode) {
                        mIsLightMode = QMUIStatusBarHelper.setStatusBarLightMode(NewPersonalIndexActivity.this);
                        mIsDarkMode = false;
                    }
                    mToolbarBack.setImageResource(R.drawable.back_blue);
                    mBtnPersonalInfo.setImageResource(R.drawable.ic_personal_info_gray);
                    mToolbarTitle.setTextColor(Color.parseColor("#2C2C2C"));
                } else if (offset < 0.8 && mIsLightMode) {
                    if (!mIsDarkMode) {
                        mIsDarkMode = QMUIStatusBarHelper.setStatusBarDarkMode(NewPersonalIndexActivity.this);
                        mIsLightMode = false;
                    }
                    mToolbarBack.setImageResource(R.mipmap.back_white);
                    mBtnPersonalInfo.setImageResource(R.drawable.ic_personal_info_white);
                    mToolbarTitle.setTextColor(Color.WHITE);
                }

                /*
                     这里有一个BUG，就是当RecyclerView滑动到底部出现加载提示的footer的时候也会将其高度
                     计算到scrollY中，但是滑动回来的时候不会将这个高度减去，所以到达顶部的时候需要直接
                     做一次修改颜色的处理，并且重新恢复scrollY = 0
                 */
                if (!mRvDynamics.canScrollVertically(-1)) {
                    scrollY = 0;
                    if (!mIsDarkMode) {
                        mIsDarkMode = QMUIStatusBarHelper.setStatusBarDarkMode(NewPersonalIndexActivity.this);
                        mIsLightMode = false;
                    }
                    mToolbarBack.setImageResource(R.mipmap.back_white);
                    mBtnPersonalInfo.setImageResource(R.drawable.ic_personal_info_white);
                    mToolbarTitle.setTextColor(Color.WHITE);
                }

                if (!mRvDynamics.canScrollVertically(1)) {
                    loadMoreData();
                }
            }
        });
    }

    /**
     * 上拉滑动加载更多数据
     */
    private void loadMoreData() {
        if (!isLoadFinished && mAdapter.getFooterView().getStatus() != FooterView.LOADING) {
            mPresenter.getPersonalDynamicResult(mUid, mToId, mLastItemNum, PAGE_SIZE);
            mAdapter.setFooterViewStatus(FooterView.LOADING);
        }
    }

    /**
     * 如果用户没有登陆就通过此方法跳转到登陆界面
     */
    private void toLogin() {
        Intent intent = new Intent(mContext, LoginActivity.class);
        startActivity(intent);
    }

    /**
     * 动态item的更多菜单
     *
     * @param context  上下文关系
     * @param position 数据所在列表中的位置
     * @param bean     所操作的数据源
     */
    public void showDynamicMenu(Context context, final int position, final PersonalDynamicBean.DataBean.NumberBean bean) {
        ActionSheet actionSheet = new ActionSheet(context);
        if (TextUtils.equals(mUid, mToId)) {
            actionSheet.builder()
                    .setCancelable(true)
                    .setCanceledOnTouchOutside(true)
                    .addSheetItem("删除", ActionSheet.SheetItemColor.Blue, new ActionSheet.OnSheetItemClickListener() {
                        @Override
                        public void onClick(int which) {
                            if ("0".equals(bean.getTableType())) {      //判断是否是转发的
                                mPresenter.deleteRelay(mUid, bean.getIdOne(), position);
                            } else {
                                mPresenter.deleteDynamic(mUid, bean.getIdOne(), position);
                            }
                        }
                    }) // 菜单条目内容
                    .show();
        }
    }

    @Override
    public void showProgress() {

    }

    @Override
    public void hideProgress() {

    }

    @Override
    public void onRequestSuccess(PersonalInfoBean bean) {
        List<PersonalInfoBean.DataBean.UserInfoBean> userInfo = bean.getData().getUserinfor();

        mPersonalInfoBean.setData(bean.getData());
        mAdapter.notifyItemChanged(0);

        String userName;
        if (!userInfo.isEmpty()) {
            PersonalInfoBean.DataBean.UserInfoBean userInfoBean = userInfo.get(0);
            // 用户名
            userName = userInfoBean.getName();
        } else {
            userName = "";
        }
        mToolbarTitle.setText(userName);
    }

    @Override
    public void onRequestFailed(Throwable throwable) {
        LogUtils.e(throwable.getMessage(), NewPersonalIndexActivity.class.getName());
        mPresenter.getUserInfo(mToId, mUid);
    }

    @Override
    public void getDynamicsSuccess(PersonalDynamicBean bean) {
        if (bean.getCode() == 200) {
            if (isRefresh) {
                isRefresh = false;
                List<PersonalDynamicBean.DataBean.NumberBean> number = bean.getData().getNumber();
                int size = number.size();
                if (size == 0) {
                    isLoadFinished = true;
                    mAdapter.setFooterStatus(FooterView.NO_MORE);
                    mAdapter.setFooterViewStatus(FooterView.NO_MORE);
                } else if (size > 0 && size < PAGE_SIZE) {
                    isLoadFinished = true;
                    mAdapter.updateData(number);
                    mAdapter.setFooterStatus(FooterView.NO_MORE);
                    mAdapter.setFooterViewStatus(FooterView.NO_MORE);
                } else {
                    isLoadFinished = false;
                    mAdapter.updateData(number);
                    mAdapter.setFooterStatus(FooterView.MORE);
                    mAdapter.setFooterViewStatus(FooterView.MORE);
                }
                mLastItemNum += size;
                if (mRefreshLayout.isRefreshing()) {
                    mRefreshLayout.setRefreshing(false);
                }
            } else {
                List<PersonalDynamicBean.DataBean.NumberBean> number = bean.getData().getNumber();
                int size = number.size();
                if (size == 0) {
                    isLoadFinished = true;
                    mAdapter.setFooterStatus(FooterView.NO_MORE);
                    mAdapter.setFooterViewStatus(FooterView.NO_MORE);
                } else if (size > 0 && size < PAGE_SIZE) {
                    isLoadFinished = true;
                    mAdapter.appendData(number);
                    mAdapter.setFooterStatus(FooterView.NO_MORE);
                    mAdapter.setFooterViewStatus(FooterView.NO_MORE);
                } else {
                    isLoadFinished = false;
                    mAdapter.appendData(number);
                    mAdapter.setFooterStatus(FooterView.MORE);
                    mAdapter.setFooterViewStatus(FooterView.MORE);
                }
                mLastItemNum += size;
                if (mRefreshLayout.isRefreshing()) {
                    mRefreshLayout.setRefreshing(false);
                }
            }
        }
    }

    @Override
    public void getDynamicsError(Throwable throwable) {
        if (retryCount < 5) {
            retryCount++;
            mPresenter.getPersonalDynamicResult(mUid, mToId, mLastItemNum, PAGE_SIZE);
        } else {
            retryCount = 0;
            LogUtils.e(throwable.getMessage(), TAG);
            showShortText("请求失败");
        }
    }

    @Override
    public void onDelDynamicSuccess(CommonBean bean, int position) {
        if (bean.getCode() == 200) {
            mAdapter.removeData(position);
        }
    }

    @Override
    public void onDelDynamicError(Throwable throwable) {
        LogUtils.e(throwable.getMessage(), NewPersonalIndexActivity.class.getName());
    }

    @Override
    public void onFollowSuccess(FollowResultBean bean) {
        PersonalInfoBean.DataBean dataBean = mAdapter.getUserInfoBean().getData();
        String state = TextUtils.equals(dataBean.getIs_concern(), "1") ? "0" : "1";
        dataBean.setIs_concern(state);
        mAdapter.notifyItemChanged(0);
    }

    @Override
    public void onFollowError(Throwable throwable) {
        LogUtils.e(throwable.getMessage(), TAG);
    }
}